#include <stdio.h>
#include <arpa/inet.h>
#include <netinet/in.h>


#define PRIVATE_IN_CLASSC(a)            ((((in_addr_t)(a)) & 0x0000a8c0) == 0x0000a8c0)
#define PRIVATE_IN_CLASSB(a)            ((((in_addr_t)(a)) & 0x000010ac) == 0x000010ac)
#define PRIVATE_IN_CLASSA(a)            ((((in_addr_t)(a)) & 0x0000000a) == 0x0000000a)


int main(int argc, char** argv)
{

	struct in_addr n_ip;
	in_addr_t res;
	char s_ip[]="172.31.0.0";
	printf("s_ip: %s\n",s_ip);

	inet_aton(s_ip,&n_ip);

	printf("n_ip: %s\n",inet_ntoa(n_ip));
	printf("ip in hex: 0x%X\n",n_ip.s_addr);

	if(PRIVATE_IN_CLASSA(n_ip.s_addr))
		printf("The ip is in private A class.\n");

	if(PRIVATE_IN_CLASSB(n_ip.s_addr))
		printf("The ip is in private B class.\n");

	if (PRIVATE_IN_CLASSC(n_ip.s_addr))
		printf("The ip is in private C class.\n");

	return 0;	


}
